package com.ybkj.daijia.server.zhuan;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author zhyu
 * @date 2019-08-17 15:54:51 缓存经纬度 准备的小型地点对象
 */
public class SmallLocation implements Serializable, Comparable<SmallLocation> {

    public static final double KILO = 1000d;
    private static final long serialVersionUID = 1L;
    private Integer id;

    private Double longitude; // 经度

    private Double latitude; // 纬度

    private Double direction;

    private Long locDate;

    private String locType;

    private String orderIds;

    private String orderType;

    private Double radius;

    private Integer run;


    public SmallLocation() {
    }

    public SmallLocation(Double longitude, Double latitude) {
        this.longitude = longitude;
        this.latitude = latitude;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    public boolean judgeTheSameLocation(SmallLocation other) {
        if (other == null) {
            return false;
        }
        if (!longitude.equals(other.longitude) || !latitude.equals(other.latitude)) {
            return false;
        }
        return true;
    }

    public Double getDirection() {
        return direction;
    }

    public void setDirection(Double direction) {
        this.direction = direction;
    }

    public Long getLocDate() {
        return locDate;
    }

    public void setLocDate(Long locDate) {
        this.locDate = locDate;
    }

    public String getLocType() {
        return locType;
    }

    public void setLocType(String locType) {
        this.locType = locType;
    }

    public String getOrderIds() {
        return orderIds;
    }

    public void setOrderIds(String orderIds) {
        this.orderIds = orderIds;
    }

    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public Double getRadius() {
        return radius;
    }

    public void setRadius(Double radius) {
        this.radius = radius;
    }

    public Integer getRun() {
        return run;
    }

    public void setRun(Integer run) {
        this.run = run;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public String toString() {
        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm:ss");
        StringBuilder sb = new StringBuilder("(");
        if (locDate != null) {
            sb.append("locDate:" + sdf.format(new Date(locDate)));
        }
        sb.append("\"" +
            "lng:" + longitude +
            ",lat:" + latitude + "," +
            ",locDate:" + locDate);
        sb.append(")");
        return sb.toString();
    }

    public String printBD() {
        return "{" +
            "\"longitude\":" + longitude +
            ",\"latitude\":" + latitude +
            ",\"loc_time\":" + locDate / 1000 +
            ",\"coord_type_input\":\"bd09ll\"" +
            "}";
    }

    public String printGD() {
        return "{" +
            "\"location\":\"" + longitude + "," + latitude + "\"" +
            ",\"locatetime\":" + locDate +
//                ",\"speed\":40," +
//                "\"direction\":120," +
//                "\"height\":39," +
//                "\"accuracy\":20" +
            "}";
    }

    @Override
    public int compareTo(SmallLocation o) {
        long l = locDate - o.getLocDate();
        if (0 == l) {
            return 0;
        }
        if (0 > l) {
            return -1;
        }
        return 1;
    }
}
